!
function(l) {
    function h(a, c) {
        0 == k(a, c) && (a.className += " " + c)
    }
    function k(a, c) {
        return !! a.className.match(new RegExp("(\\s|^)" + c + "(\\s|$)"))
    }
    function g(a, c) {
        var b = a.className;
        k(a, c) && (b = b.replace(new RegExp("(\\s|^)" + c + "(\\s|$)"), " "), b = b.replace(/(^\s*)|(\s*$)/g, ""), a.className = b)
    }
    function f(a) {
        return document.querySelector(a)
    }
    function n(a) {
        var c, b, d, e = "";
        return c = String(parseInt(a / 3600, 10)),
        b = String(parseInt(a % 3600 / 60, 10)),
        d = String(parseInt(a % 60, 10)),
        "0" != c && (1 == c.length && (c = "0" + c), e += c + ":"),
        1 == b.length && (b = "0" + b),
        e += b + ":",
        1 == d.length && (d = "0" + d),
        e + d
    }
    function p(a) {
        var c = this.config,
        b;
        for (b in a) a.hasOwnProperty(b) && (c[b] = a[b]);
        this.config = c;
        this.musicList = this.config.musicList || []; 
        (this.musicLength = this.musicList.length) && f("body") || (this.musicDom.listWrap.innerHTML = "<p>\u6682\u65e0\u64ad\u653e\u8bb0\u5f55...</p>");
        musicLists=this.musicList;
        this.audioDom = null;
        this.init()
    }
	var m=null;
    q = parseInt( - 7 * Math.random() + 9);
    p.prototype = {
		config: {
            musicList: [],
            defaultVolume: .7,
            defaultIndex: q
        },
        createListDom: function() {
            var a = 0,
            c = "<ul>";
            for (a; a < this.musicLength; a++){
            	var singer="";
            	for(var m1=0;m1<this.musicList[a].ar.length;m1++){
            		singer+=(this.musicList[a].ar[m1].name+",");
                }
            	singer=singer.substring(0,(singer.length-1));
            	c += '<li class="f-toe"><strong>' + this.musicList[a].name + "</strong> -- <small>" + singer+ "</small></li>";
            }
            this.musicDom.listWrap.innerHTML = c + "</ul>"
        },
        setBuffer: function(a, c) {
            var b = c.parentNode.offsetWidth;
            m = setInterval(function() {
                var d = a.buffered.length;
                if (0 < d && void 0 != a.buffered) {
                    var e = a.buffered.end(d - 1) / a.duration * b;
                    c.style.width = e + "px";
                    1 > Math.abs(a.duration - a.buffered.end(d - 1)) && (c.style.width = b + "px", clearInterval(m))
                }
            },
            1E4)
        },
        resetPlayer: function(a) {
            a >= this.musicLength - 1 && (a = this.musicLength - 1);
            0 >= a && (a = 0);
            this.currentMusic = a;
            var c = this.musicList[a],
            b = this,
            d = function() {
                return b.setBuffer(this, b.musicDom.bufferProcess)
            };
            this.audioDom.removeEventListener("canplay", d, !1);
            clearInterval(m);
            this.musicDom.bufferProcess.style.width = "0px";
            this.musicDom.curProcess.style.width = "0px";
            this.audioDom.src = "http://music.163.com/song/media/outer/url?id="+c.id+".mp3";
            var singer="";
            var lrc=MusicUtil.getLrc(c.id);
            for(var m1=0;m1<c.ar.length;m1++){
            	singer+=(c.ar[m1].name+",");
            }
            singer=singer.substring(0,(singer.length-1));
            this.musicDom.cover.innerHTML = '<img src="' + c.al.picUrl + '" title="' + c.name + " -- " + singer + '">';
            this.musicDom.title.innerHTML = "<strong title='"+c.name+"'>" + c.name + "</strong><small title='"+singer+"'>" + singer + "</small>";
            var c = document.querySelectorAll(".m-music-list-wrap li"),
            e = 0;
            for (e; e < this.musicLength; e++) e == a ? h(c[e], "current") : g(c[e], "current");
            this.audioDom.addEventListener("canplay", d, !1);
            this.play();
            //歌词更换
            //点击开始方法调用lrc。start歌词方法 返回时间time
			$lrc.start(lrc.lrc.lyric, function(){
				return time;
			});
        },
        setVolume: function(a) {
            var c = this.musicDom.volume,
            b = c.volumeEventer.offsetHeight || 50;
            0 >= a && (a = 0);
            1 <= a && (a = 1);
            this.audioDom.volume = a;
            b *= a;
            c.volumeCurrent.style.height = b + "px";
            c.volumeCtrlBar.style.bottom = b + "px";
            c.volumeProcess.setAttribute("data-volume", a);
            0 == a ? (h(c.volumeControl, "muted"), this.audioDom.muted = !0) : (g(c.volumeControl, "muted"), this.audioDom.muted = !1)
        },
        initPlay: function() {
            var a = this.config.defaultIndex;
            this.setVolume(this.config.defaultVolume);
            this.audioDom.load();
            this.resetPlayer(a);
			// 点击开始方法调用lrc。start歌词方法 返回时间time
			
        },
        play: function() {
        	autoHidden();
            var a = this.musicDom.button.ctrl;
            this.audioDom.play();
            time= this.audioDom.currentTime;
            g(a, "paused");
            h(a, "play");
            a.setAttribute("title", "\u6682\u505c");
            g(this.musicDom.cover, "paused");
            h(this.musicDom.cover, "play");
        },
        pause: function() {
            var a = this.musicDom.button.ctrl;
            this.audioDom.pause();
            g(a, "play");
            h(a, "paused");
            a.setAttribute("title", "\u64ad\u653e");
            g(this.musicDom.cover, "play");
            h(this.musicDom.cover, "paused")
        },
        getRandomIndex: function() {
            var a = this.currentMusic,
            c = this.musicLength,
            b = 0,
            d = [];
            for (b; c > b; b++) b != a && d.push(b);
            a = parseInt(Math.random() * d.length);
            return d[a]
        },
        playByMode: function(a) {
            var c = this.playMode,
            b = this.currentMusic,
            d = this.musicLength,
            e = b;
            1 == c ? "prev" == a ? e = d - 1 >= b && 0 < b ? b - 1 : d - 1 : ("next" == a || "ended" == a) && (e = b >= d - 1 ? 0 : b + 1) : 2 == c ? e = this.getRandomIndex() : 3 == c && (e = "prev" == a ? d - 1 >= b && 0 < b ? b - 1 : d - 1 : "next" == a ? b >= d - 1 ? 0 : b + 1 : b);
            this.resetPlayer(e)
        },
        action: function() {
            var a = this,
            c = this.musicDom.volume,
            b = this.musicDom.button;
            this.audioDom.addEventListener("timeupdate",
            function() {
                if (!isNaN(this.duration)) {
                    var b = n(this.currentTime),
                    c = n(this.duration),
                    d = this.currentTime / this.duration * a.musicDom.bufferProcess.parentNode.offsetWidth;
                    a.musicDom.time.innerHTML = "" + b + "/" + c;
                    a.musicDom.curProcess.style.width = d + "px";
					time=this.currentTime;
				}
            },
            !1);
            this.audioDom.addEventListener("ended",
            function() {
                a.playByMode("ended")
            },
            !1);
            c.volumeControl.addEventListener("click",
            function(b) {
                b = b || window.event;
                b.stopPropagation();
                k(c.volumeProcess, "show") ? (k(this, "muted") ? g(this, "muted") : h(this, "muted"), a.audioDom.muted = k(this, "muted") ? !0 : !1) : h(c.volumeProcess, "show")
            },
            !1);
            document.addEventListener("click",
            function(a) {
                a = a || window.event;
                a.stopPropagation();
                a = a.target || a.srcElement;
                a.parentNode !== c.volumeProcess && a.parentNode !== f(".grid-music-container .u-volume") && g(c.volumeProcess, "show")
            },
            !1);
            c.volumeEventer.addEventListener("click",
            function(b) {
                b = b || window.event;
                b.stopPropagation();
                var c = this.offsetHeight;
                a.setVolume((c - b.offsetY) / c)
            },
            !1);
            var d = document.querySelectorAll(".m-music-list-wrap li"),
            e = 0;
            for (e; e < this.musicLength; e++) !
            function(b) {
                d[b].addEventListener("click",
                function() {
                    a.resetPlayer(b)
                },
                !1)
            } (e);
            b.ctrl.addEventListener("click",
            function() {
                k(this, "play") ? a.pause() : a.play()
            },
            !1);
            b.prev.addEventListener("click",
            function() {
                a.playByMode("prev")
            },
            !1);
            b.next.addEventListener("click",
            function() {
                a.playByMode("next")
            },
            !1);
            b.listCircular.addEventListener("click",
            function() {
                h(this, "current");
                g(b.singleCircular, "current");
                g(b.randomPlay, "current");
                a.playMode = 1
            });
            b.randomPlay.addEventListener("click",
            function() {
                h(this, "current");
                g(b.singleCircular, "current");
                g(b.listCircular, "current");
                a.playMode = 2
            });
            b.singleCircular.addEventListener("click",
            function() {
                h(this, "current");
                g(b.listCircular, "current");
                g(b.randomPlay, "current");
                a.playMode = 3
            })
        },
        init: function() {
            this.musicDom = {
                music: f(".grid-music-container"),
                cover: f(".grid-music-container .u-cover"),
                title: f(".grid-music-container .u-music-title"),
                curProcess: f(".grid-music-container .current-process"),
                bufferProcess: f(".grid-music-container .buffer-process"),
                time: f(".grid-music-container .u-time"),
                listWrap: f(".grid-music-container .m-music-list-wrap"),
                volume: {
                    volumeProcess: f(".grid-music-container .volume-process"),
                    volumeCurrent: f(".grid-music-container .volume-current"),
                    volumeCtrlBar: f(".grid-music-container .volume-bar"),
                    volumeEventer: f(".grid-music-container .volume-event"),
                    volumeControl: f(".grid-music-container .volume-control")
                },
                button: {
                    ctrl: f(".grid-music-container .ctrl-play"),
                    prev: f(".grid-music-container .prev"),
                    next: f(".grid-music-container .next"),
                    listCircular: f(".grid-music-container .mode-list"),
                    randomPlay: f(".grid-music-container .mode-random"),
                    singleCircular: f(".grid-music-container .mode-single")
                }
            };
            this.currentMusic = this.config.randomIndex || 2;
            this.playMode = 2;
            var children=document.createElement("audio");
            this.audioDom = children;
            // this.audioDom.style("display","none");
            document.getElementsByTagName("body")[0].append(children);
            this.createListDom();
            this.initPlay();
            this.action()
        }
    };
    l = l || window;
    l.SMusic = function(a) {
        return new p(a)
    }
} (window);
$(
    $("#progressBar").click(function (event) {
        var currentProgressBar=document.querySelector('#progressBar');
        event = event || window.event;  
        // 2.获取鼠标在整个页面的位置
        var pagex = event.pageX || scroll().left + event.clientX;  
        var pagey = event.pageY || scroll().top + event.clientY;  
        // 3.获取盒子在整个页面的位置
        var xx = $('#progressBar').offset().left;
        var yy = currentProgressBar.offsetTop
        // 4.用鼠标的位置减去盒子的位置赋值给盒子的内容。
        var targetx = pagex - xx;  
        var targety = pagey - yy; 
        var newCurrentTime= targetx/currentProgressBar.offsetWidth;
        $("audio").eq(0).css("display","none");
        var audio=$("audio")[0];
        var time=audio.duration;
        audio=document.getElementsByTagName("audio")[0];
        audio.currentTime = parseInt(newCurrentTime*time);
    })
);
